package cn.itsource.test;

import cn.itsource.product.domain.TProduct;
import cn.itsource.product.mapper.ProductMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class 批量操作示例 {
    @Autowired
    private ProductMapper productMapper;

    @Test
    public void 批量查询操作(){
        //查询条件放在一个集合中
        List<Long> ids = new ArrayList();
        ids.add(69L);
        ids.add(70L);
        ids.add(71L);

        //tkmapper的批量操作 in(xxx,xx,xx)
        Example example = new Example(TProduct.class);
        example.and().andIn("id",ids);

        //执行查询操作
        List<TProduct> productList = productMapper.selectByExample(example);
        for (TProduct tProduct : productList) {
            System.out.println(tProduct);
        }



    }
}
